package demo;

import java.util.Scanner;

public class max{
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("=====请输入2个整数====");
        int num1 = getValidIntInput(scanner,"请输入第1个数字:");
        int num2 = getValidIntInput(scanner,"请输入第2个数字:");
        int ret1 = max(num1,num2);
        System.out.println("最大的整数为："+ret1);
    }
    public static int max(int a,int b){
        return Math.max(a,b);
    }
    public static double max(double a,double b,double c){
        double  ret = Math.max(a,b);
        return Math.max(ret,c);
    }
    private static int getValidIntInput(Scanner scanner,String prompt) {
        while (true) {
            System.out.println(prompt);
            if (scanner.hasNextInt()) {//判断是否为整数
                return scanner.nextInt();
            } else {
                System.out.println("输入形式错误，请重新输入");
                scanner.next();
            }
        }

    }
}
